package com.comprosoft.telnet.command;

import com.comprosoft.telnet.command.Command;
import com.comprosoft.telnet.command.CommandResult;
import com.comprosoft.telnet.configuration.ServerProperties;
import com.comprosoft.telnet.io.IOHandler;
import com.comprosoft.telnet.io.TextColor;

import java.util.ArrayList;

public final class LoginNameCommandHandler extends Command {

    private String username;
	/**
	 * Create a new list command object
	 * @param io Input/Output handler
	 */
	public LoginNameCommandHandler(IOHandler io) {
		super(io,"username");
		username = ServerProperties.LOGIN_USERNAME.getValue();
	}


	@Override
	protected com.comprosoft.telnet.command.CommandResult handleCommand(String[] args) {
		StringBuffer commandStr = new StringBuffer();
		int i = 0;
		for(String arg:args){
			if(i==1) {
				commandStr.append(arg);
				break;
			}
			i++;
		}
		if(username.equals(commandStr.toString())) {
			return com.comprosoft.telnet.command.CommandResult.COMMAND_FILLED_USERNAME;
		}else{
			return CommandResult.COMMAND_OK;
		}
	}

}
